﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WatiNSahi;
using WatiNSahi.Extensions;

using WatiN.Core;
using WatiN.Core.Native;
using WatiN.Core.Logging;
using WatiN.Core.UtilityClasses;
using WatiN.Core.Properties;
using WatiN.Core.Native.Windows;
using WatiN.Core.DialogHandlers;

namespace WatiNSahiTester
{
    class WatiNSahiFireFoxTests : WatiNSahiTest
    {


        public void _test_firefox_google()
        {
            browserName = "firefox";
            _navigateTo("http://www.google.co.in");
            _setValue(_textbox("q"),"WatiN Firefox");
            _click(_button("btnG"));
            _closeBrowser();
        }

        public void _test_enovia_login_logout()
        {
            browserName = "firefo";
            Settings.AutoMoveMousePointerToTopLeft = false;
            _navigateTo("http://enolin2plp:7045/enovia");
            
            
            

            try
            {
                _setValue(_textbox("login_name"), "PLMADM");
                _setValue(_password("login_password"), "PLMADM");
                _click(_submit("Login"));
                if (_exists(_span("ds-coachmark-close")))
                    _click(_span("ds-coachmark-close"));
                else
                    _log("Coach Mark was not present.");

                _wait(600);

                _click(_link("btn app-menu"));
                _click(_label("VPLM Administration"));
                
                //_print_browser_frames_details();

                //_log("Number of frames in the list => " + _get_browser_frames().Count);

                //Frame f = _frame("APPVPLMPerson");
                /*
                 * 
                 * APPVPLMContext' ID :: '' '
                 *  APPVPLMOrganization' ID ::
                 *  APPVPLMProject' ID :: '' '
                 *  APPVPLMRole' ID :: '' '
                 *  APPVPLMLocalAdministration
                 * */
                
                //Frame f = null;
                //foreach (var item in new string[] { "APPVPLMPerson", "APPVPLMContext", "APPVPLMOrganization",
                //    "APPVPLMProject", "APPVPLMRole", "APPVPLMLocalAdministration" })
                //{
                //    f = _frame(item);
                //    _log("Frame name is ::" + f.Name);
                //}

               
                _setValue(_textbox("plm_ExternalID", true), "*Demo*");

                _click(_link("Search",true));
                _wait_for_complete();
            }
            //catch(Exception e)
            //{
            //    _logException(string.Format("Exception of type :: '{0}' has occurred with message :: '{1}'.",e.GetType(),e.Message));
            //}
            finally
            {
                _mouseOver(_listItem("icon-button profile"));
                _click(_listItem("Sign Out"));
                _closeBrowser();
            }

        }
    }
}
